package com.fm.base.json;

import java.util.Map;

public interface JsonObject extends Map<String, JsonValue>, JsonStructure {
	JsonObject append(String key, boolean b);

	JsonObject append(String key, Number number);

	JsonObject append(String key, String string);

	default JsonObject append(String key, JsonValue value) {
		put(key, value);
		return this;
	}

	default String getString(String key) {
		JsonValue val = get(key);
		if (val == null) {
			return null;
		} else {
			return val.toString();
		}
	}

	default Number getNum(String key) {
		return ((JsonNumber) get(key)).bigDecimalValue();
	}

	default JsonArray getJsonArray(String key) {
		return (JsonArray) get(key);
	}

	default JsonObject getJsonObject(String key) {
		return (JsonObject) get(key);
	}

	JsonObject clone();
}
